<?php defined('InNcPHP') or exit('Access Invalid!');?>
<script src="//webapi.amap.com/maps?v=1.3&key=9278aff6ea76c052364dd8216fc9be47&plugin=AMap.Geocoder"></script>
<style>
    .show { display: block; }
    .hide { display: none; }
</style>

<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <h3>酒店</h3>
            <?php echo $output['top_link'];?>
        </div>
    </div>
    <div class="fixed-empty"></div>
    <?php echo $output['sub_link'];?>
    <!-- 提交表单开始 -->
    <form id="ticket_form" method="post" enctype="multipart/form-data">
        <input type="hidden" name="form_submit" value="ok" />
        <table class="table tb-type2 nobdb">
            <tbody>
            <!-- 所属商家 -->
            <tr>
                <td colspan="2" class="required">
                    <label class="validation"><?php echo $lang['ticket_index_merchant'];?>: </label>
                </td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform">
                    <select name="merchant_id">
                        <option value=""><?php echo $lang['nc_please_choose'];?>...</option>
                        <?php if (is_array($output['merchants'])): ?>
                            <?php foreach ($output['merchants'] as $k => $v): ?>
                                <option value="<?php echo $v['merchant_id']; ?>" <?php echo $output['hotel_info']['merchant_id'] == $v['merchant_id'] ? 'selected' : ''; ?>><?php echo $v['mc_shop_name']; ?></option>
                            <?php endforeach; ?>
                        <?php endif; ?>
                    </select>
                </td>
                <td class="vatop tips"></td>
            </tr>
            <!-- 名称 -->
            <tr class="noborder">
                <td colspan="2" class="required">
                    <label class="validation">酒店名称:</label>
                </td>
            </tr>

            <tr class="noborder">
                <td class="vatop rowform"><input type="text" name="title" class="txt" value="<?php echo $output['hotel_info']['hotel_name'] ?>"></td>
                <td class="vatop tips"><?php echo $lang['ticket_add_title_notice'];?></td>
            </tr>
            <!-- 分类 -->
            <tr>
                <td colspan="2" class="required">
                    <label class="validation"><?php echo $lang['ticket_index_class'];?>: </label>
                </td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform">
                <select id="cate1" name="cate1" class="class-select">
                    <option value="">选择分类</option>
                    <?php if (is_array($output['cate'])): ?>
                        <?php foreach ($output['cate'] as $k => $v): ?>
                            <option value="<?php echo $v['tc_id']; ?>" <?php echo $output['hotel_info']['cate_id'] == $v['tc_id'] ? 'selected' : ''; ?>><?php echo $v['tc_name']; ?></option>
                        <?php endforeach; ?>
                    <?php endif; ?>
                </select>
                </td>
                <td class="vatop tips"></td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label class="validation" for="hotel_tel">酒店电话:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform"><input type="text" name="hotel_tel" id="hotel_tel" value="<?php echo $output['hotel_info']['hotel_tel']?>" class="txt"></td>
                <td class="vatop tips"></td>
            </tr>

            <!-- SKU设置 -->
            <?php if(!empty($output['types'])){ ?>
                <?php foreach ($output['types'] as $type): ?>
                    <tr class="noborder type_fix">
                        <td colspan="2" class="required">
                            <label><input type="checkbox" name="types[<?php echo $type['type_id'];?>]" onclick="changeUse($(this));"><?php echo $type['type_name'];?></label>
                        </td>
                    </tr>
                    <tr class="type_fix inputs hide">
                        <td colspan="2">
                            <?php echo $lang['ticket_index_store']; ?>：<input type="text" name="store<?php echo $type['type_id'];?>">
                            <?php echo $lang['ticket_index_price']; ?>：<input type="text" name="price<?php echo $type['type_id'];?>">
                        </td>
                    </tr>
                <?php endforeach; ?>
            <?php } ?>

            <!-- 默认显示价格 -->
            <tr class="noborder">
                <td colspan="2" class="required">
                    <label class="validation">默认展示价格:</label>
                </td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform"><input type="text" name="show_price" class="txt" value="<?php echo $output['hotel_info']['ht_market_price'] ?>"></td>
                <td class="vatop tips"></td>
            </tr>


            <!-- 限时特惠 -->
           <!-- <tr>
                <td colspan="2" class="required"><?php /*echo $lang['ticket_add_discount'];*/?>: </td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform onoff">
                    <label for="discount1" class="cb-enable"><span><?php /*echo $lang['nc_yes'];*/?></span></label>
                    <label for="discount0" class="cb-disable selected"><span><?php /*echo $lang['nc_no'];*/?></span></label>
                    <input id="discount1" name="is_discount" value="1" type="radio">
                    <input id="discount0" name="is_discount" checked value="0" type="radio">
                </td>
                <td class="vatop tips"></td>
            </tr>-->
            <!-- 推荐 -->
           <!-- <tr>
                <td colspan="2" class="required"><?php /*echo $lang['ticket_add_recommend'];*/?>: </td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform onoff">
                    <label for="recommend1" class="cb-enable"><span><?php /*echo $lang['nc_yes'];*/?></span></label>
                    <label for="recommend0" class="cb-disable selected"><span><?php /*echo $lang['nc_no'];*/?></span></label>
                    <input id="recommend1" name="is_recommend" value="1" type="radio">
                    <input id="recommend0" name="is_recommend" checked value="0" type="radio">
                </td>
                <td class="vatop tips"></td>
            </tr>-->
            <!-- 首页推荐 -->
           <!-- <tr>
                <td colspan="2" class="required"><?php /*echo $lang['ticket_add_irecommend'];*/?>: </td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform onoff">
                    <label for="irecommend1" class="cb-enable"><span><?php /*echo $lang['nc_yes'];*/?></span></label>
                    <label for="irecommend0" class="cb-disable selected"><span><?php /*echo $lang['nc_no'];*/?></span></label>
                    <input id="irecommend1" name="irecommend" value="1" type="radio">
                    <input id="irecommend0" name="irecommend" checked value="0" type="radio">
                </td>
                <td class="vatop tips"></td>
            </tr>-->
            <!-- 地址 -->
            <tr>
                <td colspan="2" class="required">
                    <label class="validation"><?php echo $lang['ticket_add_area'];?>: </label>
                </td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform">
                    <select id="store_areaId_01" name="province_id" class="class-select">
                        <option value="">省份</option>
                        <?php if (is_array($output['provinces'])): ?>
                            <?php foreach ($output['provinces'] as $k => $v): ?>
                                <option value="<?php echo $v['area_id']; ?>" <?php echo $output['hotel_info']['ht_province_id'] == $v['area_id'] ? 'selected' : ''; ?>><?php echo $v['name']; ?></option>
                            <?php endforeach; ?>
                        <?php endif; ?>
                    </select>
                    <select id="store_areaId_02" name="city_id" class="class-select">
                        <option value="">城市</option>
                        <?php if (is_array($output['citys'])): ?>
                            <?php foreach ($output['citys'] as $k => $v): ?>
                                <option value="<?php echo $v['area_id']; ?>" <?php echo $output['hotel_info']['ht_city_id'] == $v['area_id'] ? 'selected' : ''; ?>><?php echo $v['name']; ?></option>
                            <?php endforeach; ?>
                        <?php endif; ?>
                    </select>
                    <select id="store_areaId_03" name="area_id" class="class-select">
                        <option value="">区/县</option>
                        <?php if (is_array($output['areas'])): ?>
                            <?php foreach ($output['areas'] as $k => $v): ?>
                                <option value="<?php echo $v['area_id']; ?>" <?php echo $output['hotel_info']['ht_area_id'] == $v['area_id'] ? 'selected' : ''; ?>><?php echo $v['name']; ?></option>
                            <?php endforeach; ?>
                        <?php endif; ?>
                    </select>
                </td>
                <td class="vatop tips"></td>
            </tr>
            <!-- 详细地址 -->
            <tr class="noborder">
                <td colspan="2" class="required">
                    <label class="validation"><?php echo $lang['ticket_add_addr'];?>:</label>
                </td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform"><input type="text" name="addr" id="addr" class="txt" value="<?php echo $output['hotel_info']['ht_addr']; ?>"></td>
                <td class="vatop tips"><?php echo $lang['ticket_add_addr_notice'];?></td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label class="validation" for="store_location">店铺经纬度lng&lat:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform"><input type="text" value="<?php echo $output['hotel_info']['hotel_lng'];?>,<?php echo $output['hotel_info']['hotel_lat'];?>" name="store_location" readonly="true" id="store_location" class="txt"></td>
                <td class="vatop tips"></td>
            </tr>

            <tr class="noborder">
                <td class="vatop rowform"><button type="button" class="btn" id="getMapLocation">地图获取坐标</button></td>
                <td class="vatop tips"></td>
            </tr>
            <!-- 封面图片 -->
            <tr class="noborder">
                <td colspan="2" class="required">
                    <label class="validation"><?php echo $lang['ticket_add_image'];?>:</label>
                </td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform">
                        <span class="type-file-show">
                        <img class="show_image" src="<?php echo ADMIN_TEMPLATES_URL;?>/images/preview.png">
                        <div class="type-file-preview" style="display: none;">
                            <img id="view_img" src="<?php echo $output['hotel_info']['hotel_thumb']; ?>" style="max-height: 100px;max-width: 100px;">
                        </div>

                    </span> <span class="type-file-box">
                        <input type='text' name='textfield' id='textfield' class='type-file-text' />
                        <input type='button' name='button' id='button' value='' class='type-file-button' />
                        <input name="thumb" type="file" class="type-file-file" id="image" size="30" hidefocus="true" />
                    </span>
                </td>
                <td class="vatop tips"><?php echo $lang['ticket_add_image_notice'];?></td>
            </tr>
            <!-- 详情页图片 -->
            <!--<tr class="noborder">
                <td colspan="2" class="required">
                    <label class="validation"><?php echo $lang['ticket_add_face'];?>:</label>
                </td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform"><span class="type-file-show">
                    </span> <span class="type-file-box">
                        <input type='text' name='textfield' id='textfield1' class='type-file-text' />
                        <input type='button' name='button' id='button' value='' class='type-file-button' />
                        <input name="face" type="file" class="type-file-file" id="image1" size="30" hidefocus="true" />
                    </span>
                </td>
                <td class="vatop tips"><?php echo $lang['ticket_add_face_notice'];?></td>
            </tr>-->
            <!-- 酒店介绍 -->
            <tr class="noborder">
                <td colspan="2" class="required">
                    <label class="validation">酒店介绍:</label>
                </td>
            </tr>
            <tr class="noborder">
                <td colspan="2" class="vatop rowform">
                    <textarea id="content" name="content" style="width:70%;height: 400px;"><?php echo $output['hotel_info']['hotel_content'] ?></textarea>
                </td>
            </tr>

            </tbody>

            <tr>
                <th colspan="2">
                    <a href="JavaScript:void(0);"  class="add_goods_size"  style="display:block; width: 65px; height: 25px; line-height: 1.5rem; background-color: #24CA71;color: #FFF; text-align: center">+ 添加房型</a>
                    您可以添加多种房型；房型名称可以自定义，若每个房型下开启规格,请先提交保存再编辑
                </th>
            </tr>



            <tr>
                <td colspan="2">
                    <table class="table tb-type2 goods ">
                        <tbody class="goods_size1">
                        <tr>
                            <th>序号</th>
                            <th>房型名称</th>
                            <th>标签</th>
                            <th>协议价(平台填写)</th>
                            <th>原价(平台填写)</th>
                            <th>售价(平台填写)</th>
                            <th>房间数量</th>
                            <th>是否上架</th>
                            <th> 操作</th>
                        </tr>
                        <?php foreach($output['spec_list'] as $ke =>$v){ ?>
                        <tr >
                            <td class="w10">
                                <?php echo $v['spec_sort'];?><input type="hidden" name="gs_sort[]"  class="gs_sort" value="<?php echo $v['spec_sort'] ?>">
                                <input type="hidden" name="spec_id[]" value="<?php echo $v['spec_id']; ?>">
                            </td>
                            <td class="w15"><input type="text" name="spec_name[]"  class="goods_size" value="<?php echo $v['spec_name']; ?>"></td>
                            <td class="w15"><input type="text" value="<?php echo $v['label'];  ?>" name="label[]"  class="label"></td>
                            <td class="w15"><input type="text" value="<?php echo $v['cost_price']; ?>"  name="cost_price[]" <?php if($output['admin_info']['merchant_id']>0){ ?>  readonly="true"  <?php } ?>  class="goods_first_price"></td>
                            <td class="w15"><input type="text" value="<?php echo $v['market_price']; ?>" name="market_price[]"  <?php if($output['admin_info']['merchant_id']>0){ ?>  readonly="true"  <?php } ?>  class="goods_first_price"></td>
                            <td class="w15"><input type="text" value="<?php echo $v['price']; ?>" name="price[]"  <?php if($output['admin_info']['merchant_id']>0){ ?>  readonly="true"  <?php } ?>   class="goods_second_price"></td>
                            <td class="w10"><input type="text" value="<?php echo $v['stock'] ?>" name="stock[]"  class="goods_three_price"></td>
                            <td class="w10">
                                <select name="spec_is_show[]">
                                    <option value="1" <?php echo $v['is_show']==1?"selected":""; ?>>上架</option>
                                    <option value="0"  <?php echo $v['is_show']==0?'selected':''; ?>>下架</option>
                                </select>
                            </td>
                            <!--<td class="w10"><input type="text" value="0" name="goods_price[]"  class="goods_price"></td>
                            <td class="w10"><input type="text" value="0" name="goods_stock[]"  class="goods_stock"></td>-->
                            <td class="w10">
                                <a class="delete_size edit" href="index.php?act=hotel&op=spec_edit&spec_id=<?php echo $v['spec_id']; ?>" >编辑</a>
                            </td>
                            <td class="w10" >
                            <?php if(count($output['spec_list'])>1&&$ke+1==count($output['spec_list'])){ ?>
                                <a class="delete_size delete" data-id="<?php echo $v['spec_id'] ?>" href="JavaScript:void(0);" >删除</a>
                            <?php }else{ ?>

                            <?php } ?>
                            </td>
                        </tr>
                        <?php  }?>
                        </tbody>
                    </table>
                </td>
            </tr>
            <script>
                var i = <?php echo count($output['spec_list']) ?>;
                $('.add_goods_size').click(function () {
                    $('.delete').hide();
                    i++;
                    var html = ' <tr ><td class="w10">'+i+'<input type="hidden" name="gs_sort[]"  class="gs_sort" value="'+i+'"> </td> <td class="w15"><input type="text" ' +
                        ' name="spec_name[]"  class="goods_size"></td>  <td class="w15"><input type="text" value=""  ' +
                        ' name="label[]"  class="goods_no"></td>  ' +
                        '<td class="w15"><input type="text" value="0"  '+
                        ' name="cost_price[]"   class="goods_cost_price"></td>  '+
                        '<td class="w15"><input type="text" value="0"  ' +
                        ' name="market_price[]"   <?php if($output["admin_info"]["merchant_id"]>0){ ?>  readonly="true"  <?php } ?> class="goods_area_agent_price"></td>  ' +
                        '<td class="w15"><input type="text" value="0" name="price[]"  <?php if($output["admin_info"]["merchant_id"]>0){ ?> readonly="true"  <?php } ?>  class="goods_unite_price">' +
                        '</td><td class="w10"><input type="text" value="0" name="stock[]"  class="goods_first_price">' +
                        '<td class="w10"><select name="spec_is_show[]"><option value="1">上架</option> <option value="0">下架</option> </select> </td>'+
                        ' <td class="w10"><a class="delete_size delete" href="JavaScript:void(0);" >删除</a></td></tr>';

                    $('.goods_size1').append(html);
                });

                $('.goods_size1').on('click','.delete',function () {
                    i--;
                    //上一个 打开删除
                    $('.goods_size1').find('tr').eq($(this).parent().parent().index()-1).find('.delete').show();
                    //$(this).parent().parent('tr').remove();
                    var spec_id = $(this).attr('data-id');
                    var obj = $(this);
                    if(spec_id>0){
                        layer.confirm('您确定删除该规格', {
                            btn: ['确认','取消'] //按钮
                        }, function(){
                            $.ajax({
                                type:'post',
                                url:'index.php?act=hotel&op=delete_spec',
                                data:{spec_id:spec_id},
                                dataType:'json',
                                success:function(data){
                                    if(data.tab == 'success') {
                                        layer.msg(data.info,{icon: 1});
                                        obj.parent().parent('tr').remove();
                                    }else{
                                        layer.msg(data.info,{icon: 5});
                                        return;
                                    }
                                }
                            });
                        }, function(){
                            layer.msg('取消操作',{icon: 5});
                        });
                    }else{
                        obj.parent().parent('tr').remove();
                    }

//                  var rs = $(this).parent().parent('tr').prev('tr').children('td').children('.delete');
//                  rs.show(100);
//                  console.log(rs);
//                  $('.delete').show();

                });

            </script>
            <tfoot>

            <tbody>
            <tr>
                <td colspan="2" class="required"><label class="validation" for="hotel_param_wifi">网络设施:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform" colspan="2">
                    <input type="radio" name="hotel_param_wifi" value="不提供wifi" id="hotel_param_wifi_0"<?php if('不提供wifi'==$output['hotel_info']['hotel_param_wifi']){?> checked="checked"<?php }?>><label for="hotel_param_wifi_0">不提供wifi</label>
                    <input type="radio" name="hotel_param_wifi" value="酒店各处提供wifi" id="hotel_param_wifi_1"<?php if('酒店各处提供wifi'==$output['hotel_info']['hotel_param_wifi']){?> checked="checked"<?php }?>><label for="hotel_param_wifi_1">酒店各处提供wifi</label>
                    <input type="radio" name="hotel_param_wifi" value="公共区域和部分房间提供wifi" id="hotel_param_wifi_2"<?php if('公共区域和部分房间提供wifi'==$output['hotel_info']['hotel_param_wifi']){?> checked="checked"<?php }?>><label for="hotel_param_wifi_2">公共区域和部分房间提供wifi</label>
                </td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label class="validation" for="hotel_param_part">停车场:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform" colspan="2">
                    <input type="radio" name="hotel_param_part" value="不提供" id="hotel_param_part_0"<?php if('不提供'==$output['hotel_info']['hotel_param_part']){?> checked="checked"<?php }?>><label for="hotel_param_part_0">不提供</label>
                    <input type="radio" name="hotel_param_part" value="酒店提供免费停车位" id="hotel_param_part_1"<?php if('酒店提供免费停车位'==$output['hotel_info']['hotel_param_part']){?> checked="checked"<?php }?>><label for="hotel_param_part_1">酒店提供免费停车位</label>
                    <input type="radio" name="hotel_param_part" value="酒店提供收费停车位" id="hotel_param_part_2"<?php if('酒店提供收费停车位'==$output['hotel_info']['hotel_param_part']){?> checked="checked"<?php }?>><label for="hotel_param_part_2">酒店提供收费停车位</label>
                </td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label for="hotel_param_room">房间设施:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform" colspan="2">
                    <input type="checkbox" name="hotel_param_room[]" value="宽带上网" id="hotel_param_room_0"<?php if(in_array('宽带上网', explode(',', $output['hotel_info']['hotel_param_room']))){?> checked="checked"<?php }?>><label for="hotel_param_room_0">宽带上网</label>
                    <input type="checkbox" name="hotel_param_room[]" value="免费市内电话" id="hotel_param_room_1"<?php if(in_array('免费市内电话', explode(',', $output['hotel_info']['hotel_param_room']))){?> checked="checked"<?php }?>><label for="hotel_param_room_1">免费市内电话</label>
                    <input type="checkbox" name="hotel_param_room[]" value="空调" id="hotel_param_room_2"<?php if(in_array('空调', explode(',', $output['hotel_info']['hotel_param_room']))){?> checked="checked"<?php }?>><label for="hotel_param_room_2">空调</label>
                    <input type="checkbox" name="hotel_param_room[]" value="国际长途电话" id="hotel_param_room_3"<?php if(in_array('国际长途电话', explode(',', $output['hotel_info']['hotel_param_room']))){?> checked="checked"<?php }?>><label for="hotel_param_room_3">国际长途电话</label>
                    <input type="checkbox" name="hotel_param_room[]" value="免费国内长途电话" id="hotel_param_room_4"<?php if(in_array('免费国内长途电话', explode(',', $output['hotel_info']['hotel_param_room']))){?> checked="checked"<?php }?>><label for="hotel_param_room_4">免费国内长途电话</label>
                    <input type="checkbox" name="hotel_param_room[]" value="吹风机" id="hotel_param_room_5"<?php if(in_array('吹风机', explode(',', $output['hotel_info']['hotel_param_room']))){?> checked="checked"<?php }?>><label for="hotel_param_room_5">吹风机</label>
                    <input type="checkbox" name="hotel_param_room[]" value="24小时热水" id="hotel_param_room_6"<?php if(in_array('24小时热水', explode(',', $output['hotel_info']['hotel_param_room']))){?> checked="checked"<?php }?>><label for="hotel_param_room_6">24小时热水</label>
                    <input type="checkbox" name="hotel_param_room[]" value="暖气" id="hotel_param_room_7"<?php if(in_array('暖气', explode(',', $output['hotel_info']['hotel_param_room']))){?> checked="checked"<?php }?>><label for="hotel_param_room_7">暖气</label>
                </td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label for="hotel_param_service">酒店服务:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform" colspan="2">
                    <input type="checkbox" name="hotel_param_service[]" value="接站服务收费" id="hotel_param_service_0"<?php if(in_array('接站服务收费', explode(',', $output['hotel_info']['hotel_param_service']))){?> checked="checked"<?php }?>><label for="hotel_param_service_0">接站服务收费</label>
                    <input type="checkbox" name="hotel_param_service[]" value="接站服务免费" id="hotel_param_service_1"<?php if(in_array('接站服务免费', explode(',', $output['hotel_info']['hotel_param_service']))){?> checked="checked"<?php }?>><label for="hotel_param_service_1">接站服务免费</label>
                    <input type="checkbox" name="hotel_param_service[]" value="接机服务收费" id="hotel_param_service_2"<?php if(in_array('接机服务收费', explode(',', $output['hotel_info']['hotel_param_service']))){?> checked="checked"<?php }?>><label for="hotel_param_service_2">接机服务收费</label>
                    <input type="checkbox" name="hotel_param_service[]" value="接机服务免费" id="hotel_param_service_3"<?php if(in_array('接机服务免费', explode(',', $output['hotel_info']['hotel_param_service']))){?> checked="checked"<?php }?>><label for="hotel_param_service_3">接机服务免费</label>
                    <input type="checkbox" name="hotel_param_service[]" value="接待外宾" id="hotel_param_service_4"<?php if(in_array('接待外宾', explode(',', $output['hotel_info']['hotel_param_service']))){?> checked="checked"<?php }?>><label for="hotel_param_service_4">接待外宾</label>
                    <input type="checkbox" name="hotel_param_service[]" value="洗衣服务" id="hotel_param_service_5"<?php if(in_array('洗衣服务', explode(',', $output['hotel_info']['hotel_param_service']))){?> checked="checked"<?php }?>><label for="hotel_param_service_5">洗衣服务</label>
                    <input type="checkbox" name="hotel_param_service[]" value="行李寄存" id="hotel_param_service_6"<?php if(in_array('行李寄存', explode(',', $output['hotel_info']['hotel_param_service']))){?> checked="checked"<?php }?>><label for="hotel_param_service_6">行李寄存</label>
                    <input type="checkbox" name="hotel_param_service[]" value="看护小孩服务" id="hotel_param_service_7"<?php if(in_array('看护小孩服务', explode(',', $output['hotel_info']['hotel_param_service']))){?> checked="checked"<?php }?>><label for="hotel_param_service_7">看护小孩服务</label>
                    <input type="checkbox" name="hotel_param_service[]" value="租车" id="hotel_param_service_8"<?php if(in_array('租车', explode(',', $output['hotel_info']['hotel_param_service']))){?> checked="checked"<?php }?>><label for="hotel_param_service_8">租车</label>
                    <input type="checkbox" name="hotel_param_service[]" value="携带宠物" id="hotel_param_service_9"<?php if(in_array('携带宠物', explode(',', $output['hotel_info']['hotel_param_service']))){?> checked="checked"<?php }?>><label for="hotel_param_service_9">携带宠物</label>
                    <input type="checkbox" name="hotel_param_service[]" value="叫醒服务" id="hotel_param_service_10"<?php if(in_array('叫醒服务', explode(',', $output['hotel_info']['hotel_param_service']))){?> checked="checked"<?php }?>><label for="hotel_param_service_10">叫醒服务</label>
                </td>
            </tr>
            <tr>
                <td colspan="2" class="required"><label for="hotel_param_base">酒店设施:</label></td>
            </tr>
            <tr class="noborder">
                <td class="vatop rowform" colspan="2">
                    <input type="checkbox" name="hotel_param_base[]" value="西式餐厅" id="hotel_param_base_0"<?php if(in_array('西式餐厅', explode(',', $output['hotel_info']['hotel_param_base']))){?> checked="checked"<?php }?>><label for="hotel_param_base_0">西式餐厅</label>
                    <input type="checkbox" name="hotel_param_base[]" value="中式餐厅" id="hotel_param_base_1"<?php if(in_array('中式餐厅', explode(',', $output['hotel_info']['hotel_param_base']))){?> checked="checked"<?php }?>><label for="hotel_param_base_1">中式餐厅</label>
                    <input type="checkbox" name="hotel_param_base[]" value="残疾人设施" id="hotel_param_base_2"<?php if(in_array('残疾人设施', explode(',', $output['hotel_info']['hotel_param_base']))){?> checked="checked"<?php }?>><label for="hotel_param_base_2">残疾人设施</label>
                    <input type="checkbox" name="hotel_param_base[]" value="室外游泳池" id="hotel_param_base_3"<?php if(in_array('室外游泳池', explode(',', $output['hotel_info']['hotel_param_base']))){?> checked="checked"<?php }?>><label for="hotel_param_base_3">室外游泳池</label>
                    <input type="checkbox" name="hotel_param_base[]" value="室内游泳池" id="hotel_param_base_4"<?php if(in_array('室内游泳池', explode(',', $output['hotel_info']['hotel_param_base']))){?> checked="checked"<?php }?>><label for="hotel_param_base_4">室内游泳池</label>
                    <input type="checkbox" name="hotel_param_base[]" value="会议室" id="hotel_param_base_5"<?php if(in_array('会议室', explode(',', $output['hotel_info']['hotel_param_base']))){?> checked="checked"<?php }?>><label for="hotel_param_base_5">会议室</label>
                    <input type="checkbox" name="hotel_param_base[]" value="健身房" id="hotel_param_base_6"<?php if(in_array('健身房', explode(',', $output['hotel_info']['hotel_param_base']))){?> checked="checked"<?php }?>><label for="hotel_param_base_6">健身房</label>
                    <input type="checkbox" name="hotel_param_base[]" value="SPA" id="hotel_param_base_7"<?php if(in_array('SPA', explode(',', $output['hotel_info']['hotel_param_base']))){?> checked="checked"<?php }?>><label for="hotel_param_base_7">SPA</label>
                    <input type="checkbox" name="hotel_param_base[]" value="无烟房" id="hotel_param_base_8"<?php if(in_array('无烟房', explode(',', $output['hotel_info']['hotel_param_base']))){?> checked="checked"<?php }?>><label for="hotel_param_base_8">无烟房</label>
                    <input type="checkbox" name="hotel_param_base[]" value="商务中心" id="hotel_param_base_9"<?php if(in_array('商务中心', explode(',', $output['hotel_info']['hotel_param_base']))){?> checked="checked"<?php }?>><label for="hotel_param_base_9">商务中心</label>
                    <input type="checkbox" name="hotel_param_base[]" value="酒吧" id="hotel_param_base_10"<?php if(in_array('酒吧', explode(',', $output['hotel_info']['hotel_param_base']))){?> checked="checked"<?php }?>><label for="hotel_param_base_10">酒吧</label>
                    <input type="checkbox" name="hotel_param_base[]" value="桑拿" id="hotel_param_base_11"<?php if(in_array('桑拿', explode(',', $output['hotel_info']['hotel_param_base']))){?> checked="checked"<?php }?>><label for="hotel_param_base_11">桑拿</label>
                    <input type="checkbox" name="hotel_param_base[]" value="温泉" id="hotel_param_base_12"<?php if(in_array('温泉', explode(',', $output['hotel_info']['hotel_param_base']))){?> checked="checked"<?php }?>><label for="hotel_param_base_12">温泉</label>
                    <input type="checkbox" name="hotel_param_base[]" value="棋牌室" id="hotel_param_base_13"<?php if(in_array('棋牌室', explode(',', $output['hotel_info']['hotel_param_base']))){?> checked="checked"<?php }?>><label for="hotel_param_base_13">棋牌室</label>
                </td>
            </tr>
            </tbody>
            <!-- 提交 -->
            <tr class="tfoot">
                <td colspan="2" >
                    <a href="JavaScript:void(0);" class="btn" id="submitBtn">
                        <span><?php echo $lang['nc_submit'];?></span>
                    </a>
                </td>
            </tr>
            </tfoot>
        </table>
    </form>
</div>

<script type="text/javascript" SRC="./resource/kindeditor/kindeditor-min.js"></script>
<script>
    //门票类型改变选中状态（儿童票、成人票等）
    function changeUse(obj) {
        var td = obj.parent().parent().parent().next();
        if (obj.is(':checked') == false) {
            td.hide().find('input').val('');
        } else {
            td.show();
        }
    }
    //价格类型改变事件（固定价格、每日价格）
    $('input[name="type"]').change(function () {
        if (this.value == 0) {
            $('.type_fix:not(.inputs)').show();
        } else {
            $('input[name^="types"]:checked').each(function (i) {
                changeUse($(this).prop('checked',false));
            });
            $('.type_fix').hide();
        }
    });
    //提交表单
    $("#submitBtn").click(function(){
        if ($("#ticket_form").valid()) {
            if (parseInt($('input[name="type"]:checked').val()) === 0 && $('input[name^="types"]:checked').length === 0) {
                layer.alert('<?php echo $lang['ticket_add_use_null']; ?>', function (index) {
                    $('html,body').animate({scrollTop: $('input[name^="types"]:eq(0)').offset().top - 100}, 300);
                    layer.close(index);
                });
            } else {
                //alert('debug:表单校验ok');
                $("#ticket_form").submit();
            }
        } else {
            $('html,body').animate({scrollTop: $('label.error:visible:eq(0)').offset().top - 70}, 300);
        }
    });
    //实例化富文本编辑器
    KindEditor.ready(function(K){
        K.create('textarea[name="content"]', {
            themeType: 'simple',
            resizeType: 1,
            uploadJson: './resource/kindeditor/php/upload_json.php',
            fileManagerJson: './resource/kindeditor/php/file_manager_json.php',
            allowFileManager: true,
            afterBlur: function(){this.sync();}
        });
        K.create('textarea[name="content1"]', {
            themeType: 'simple',
            resizeType: 1,
            uploadJson: './resource/kindeditor/php/upload_json.php',
            fileManagerJson: './resource/kindeditor/php/file_manager_json.php',
            allowFileManager: true,
            afterBlur: function(){this.sync();}
        });
    });
    //选择省份
    $("#store_areaId_01").change(function(){

        var _areaID = $(this).val();
        _this = $("#store_areaId_01");
        if(_areaID){
            $.getJSON("./index.php?act=common&op=getAreaChild&parent_id=" + _areaID, function(data){
                $obj = $("#store_areaId_02");
                $obj.empty();
                $obj.append('<option value="">城市</option>');
                $obj.nextAll("select").empty();
                $obj.nextAll("select").append('<option value="">区/县</option>');
                $.each(data, function(i,item){
                    $obj.append('<option value="'+item.area_id+'">'+item.name+'</option>');
                });
            });
        }else{
            _this.nextAll("select").empty();
            _this.next("select").append('<option value="">城市</option>');
            _this.next("select").next('select').append('<option value="">区/县</option>');
        }
    });
    //选择城市
    $("#store_areaId_02").change(function(){
        var _areaID = $(this).val();
        _this = $("#store_areaId_2");
        if(_areaID){
            $.getJSON("index.php?act=common&op=getAreaChild&parent_id=" + _areaID, function(data){
                $obj = $("#store_areaId_03");
                $obj.empty();
                $obj.append('<option value="">区/县</option>');
                $.each(data, function(i,item){
                    $obj.append('<option value="'+item.area_id+'">'+item.name+'</option>');
                });
            });
        }else{
            _this.nextAll("select").empty();
            _this.next("select").append('<option value="">区/县</option>');
        }
    });
    //选择区/县
    $("#store_areaId_03").change(function(){
        var _areaID = $(this).val();
        if(_areaID){
            var area_p = $("#store_areaId_01").find("option:selected").text();
            var area_c = $("#store_areaId_02").find("option:selected").text();
            var area_a = $("#store_areaId_03").find("option:selected").text();
        }
    });
    //选择一级分类
    /*    $("#cate1").change(function(){
     var _tcId = $(this).val();
     _this = $(this);
     if(_tcId){
     $.getJSON("index.php?act=common&op=getCategory&tc_pid=" + _tcId, function(data){
     $obj = $("#cate2");
     $obj.empty();
     $obj.append('<option value="">选择二级分类</option>');
     $.each(data, function(i,item){
     $obj.append('<option value="'+item.tc_id+'">'+item.tc_name+'</option>');
     });
     });
     }else{
     _this.next("select").empty();
     _this.next("select").append('<option value="">选择二级分类</option>');
     }
     });*/
    //图片文件选择
    $("#image").change(function(){
        $("#textfield").val($(this).val());
    });
    //图片文件选择
    $("#image1").change(function(){
        $("#textfield1").val($(this).val());
    });


    //获取经纬度
    $(document).on("click","#getMapLocation",function(){
        var proviceId= $("#store_areaId_01").val();
        var cityId = $("#store_areaId_02").val();
        var areaId = $("#store_areaId_03").val();
        if(cityId == ''){
            alert('请先选择所在地区');
            return false;
        }
        /*    if($("#store_areaId_3 option").length!=1&&areaId == ''){
         alert('请先选择所在区县');
         return false;
         }*/
        $.ajax({
            type: "GET",
            url: "index.php",
            data: {act:'common',op:'bdmap',proviceId:proviceId,cityId:cityId,areaId:areaId,store_address:$("#addr").val()},
            dataType: "html",
            success: function(data){
                $('body').append(data);
            }
        });
    });

    //表单校验
    $("#ticket_form").validate({
        errorPlacement: function(error, element){
            if (element.attr('type') === 'file') {
                error.appendTo(element.parent().parent().parent().prev().find('td:first'));
            } else {
                error.appendTo(element.parent().parent().prev().find('td:first'));
            }
        },
        rules: {
            merchant_id: 'required',
            title: {
                required: true,
                minlength: 3,
                maxlength: 20
            },
            subtitle: {
                required: true,
                minlength: 3,
                maxlength: 255
            },
            cate1: 'required',
            /*cate2: 'required',*/

            show_price: {
                required: true,
                number: true,
                min: 0.01,
                max: 9999999
            },
            market_price: {
                required: true,
                number: true,
                min: 0.01,
                max: 9999999
            },
            province_id: 'required',
            city_id: 'required',
            area_id: 'required',
            addr: 'required',
            /*thumb: 'required',*/
            face: 'required',
            content: 'required',
            content1: 'required',
            hotel_tel:'required',
        },
        messages : {
            merchant_id: '<?php echo $lang['ticket_add_merchant_null']; ?>',
            title: '<?php echo $lang['ticket_add_title_notice']; ?>',
            subtitle: '<?php echo $lang['ticket_add_title_notice']; ?>',
            cate1: '请选择分类',
            cate2: '<?php echo $lang['ticket_add_cate2_null']; ?>',

            show_price: '<?php echo $lang['ticket_add_price_notice']; ?>',
            market_price: '<?php echo $lang['ticket_add_price_notice']; ?>',
            province_id: '<?php echo $lang['ticket_add_province_null']; ?>',
            city_id: '<?php echo $lang['ticket_add_city_null']; ?>',
            area_id: '<?php echo $lang['ticket_add_area_null']; ?>',
            addr: '<?php echo $lang['ticket_add_addr_null']; ?>',
           /* thumb: '<?php echo $lang['ticket_add_image_null']; ?>',*/
            face: '<?php echo $lang['ticket_add_image_null']; ?>',
            content: '<?php echo $lang['ticket_add_detail_null']; ?>',
            content1: '<?php echo $lang['ticket_add_tips_null']; ?>',
            hotel_tel:'酒店电话不能为空'
        }
    });
</script>
